import React, { Component } from "react";
import ReactDOM from "react-dom";
import { toast, base, createPage, getMultiLang } from "nc-lightapp-front";
import { afterEvent, searchClick } from "./events";
import initTemplate from "./initTemplate";
import Total from "./Total";
import "./index.less";

window.loanPageCode = {
  searchPage: "201102BCLF_FPLC",
};
window.loanDetailConfig = {
  searchArea: "202102JOIN",
  billsArea: "head",
  bodyArea: "head",
};

export default class LoanDetail extends Component {
  constructor(props) {
    super(props);
    this.state = {
        total: {
            bbjyTotla:0,
            amountRepaidTotal:0,
            repaymentingTotal:0,
            amountToBeRepaidTotal:0
        }
    }
    props.use.search(window.loanDetailConfig.searchArea);
    props.use.table(window.loanDetailConfig.bodyArea);
    this.multiLangJson = {}; // 增加多语
  }

  componentDidMount() {
    initTemplate.call(this, this.props);
    // 获取多语
    getMultiLang({
      moduleId: 2011,
      domainName: 'erm',
      callback: (json) => {
        this.multiLangJson = json
      }
  })
  }

  render() {
    let { search, table } = this.props;
    let { NCCreateSearch } = search;
    let { createSimpleTable } = table;

    return (
      <div className="container">
        <Total {...this.state.total} />

        {/* 查询区域 */}
        <div className="search-area">
          {NCCreateSearch(
            window.loanDetailConfig.searchArea, //模块id
            {
              clickPlanEve: searchClick.bind(this), //点击高级面板中的查询方案事件
              clickSearchBtn: searchClick.bind(this), //   点击按钮事件
              defaultConditionsNum: 1, //默认显示几个查询条件
            }
          )}
        </div>

        {/* 列表显示区域 */}
        <div className="list-area">
          {createSimpleTable(window.loanDetailConfig.bodyArea, {
            inModal:true,
            adaptionHeight:false,
            onAfterEvent: afterEvent.bind(this),
            showCheck: false,
            showIndex: true,
          })}
        </div>
      </div>
    );
  }
}

LoanDetail = createPage({
  mutiLangCode: "2011",
})(LoanDetail);

// ReactDOM.render(<LoanDetail />, document.querySelector('#app'))
